// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: donggu

#include <experimental/filesystem>

#include <doctest.h>
#include <nanobench.h>

#include "coin2/app/driver.h"
#include "coin2/app/driver.pb.h"
#include "coin2/base/config/app_config.h"
#include "coin2/strategy/strategy.h"

using coin2::app::Driver;
using coin2::app::DriverConfig;
using coin2::exchange::base::feed::FeedUpdate;
using coin2::strategy::IStrategy;

void run(const std::experimental::filesystem::path& path) {
  ankerl::nanobench::Bench().run(path.stem().c_str(), [&] {
    DriverConfig config = coin2::base::config::DriverConfigFromJson(path);
    IStrategy s;
    Driver driver(config, &s);
    driver.Run(false);
  });
}

// Re-organize configs if there are many

DOCTEST_TEST_CASE("bench read raw-feed") {
  DOCTEST_SUBCASE("spot coinone") { run("data/test/config/feed-raw-coinone.json"); }
  DOCTEST_SUBCASE("spot okex") { run("data/test/config/feed-raw-okex.json"); }
  DOCTEST_SUBCASE("spot quoinex") { run("data/test/config/feed-raw-quoinex.json"); }
  DOCTEST_SUBCASE("spot upbit") { run("data/test/config/feed-raw-upbit.json"); }
}

DOCTEST_TEST_CASE("bench read fastfeed") {
  DOCTEST_SUBCASE("spot binance") { run("data/test/config/feed-fastfeed-binance.json"); }
  DOCTEST_SUBCASE("futures bitmex") { run("data/test/config/feed-fastfeed-bitmex.json"); }
  DOCTEST_SUBCASE("spot upbit") { run("data/test/config/feed-fastfeed-upbit.json"); }
}
